#include <iostream>
#include <chrono>
#include <unistd.h>

#include "timer_wheel.h"

using namespace std;


int main() {
//    auto start = std::chrono::steady_clock::now();
//    usleep(5058648);
//    auto now = std::chrono::steady_clock::now();
//
//    chrono::duration<double, milli> dur = chrono::duration_cast<chrono::duration<double, milli>>(now - start);
//
//    cout << dur.count() << endl;

    int step_ms = 50;
    TimerWheel::TimerWheels tws(step_ms);
    tws.append_wheel(1000 / step_ms, step_ms, "MillisecondWheel");
    tws.append_wheel(60, 1000, "SecondWheel");
    tws.append_wheel(60, 60 * 1000, "MinuteWheel");
    tws.append_wheel(60, 60 * 60 * 1000, "HourWheel");

    tws.start();

    tws.add_timer(1, 500, [] () {
        cout << "500ms task." << endl;
    });

//    tws.add_timer(2, 6 * 60 * 1000, [] () {
//        cout << "6min task." << endl;
//    });
//
//    tws.add_repeated_timer(1, 30 * 1000, [] () {
//        cout << "30s repeated task." << endl;
//    });

    std::this_thread::sleep_for(std::chrono::milliseconds(2*1000));
    tws.stop();

    return 0;
}